/*
 * Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
 *
 * Licensed under the Mulan PSL v2.
 * You can use this file according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of the License at
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
 * FOR MORE DETAILS.
 */

#pragma once
#include "highfive/H5File.hpp"

#include "DBManager/IRepository/Result/ElementalStrain/ITRIA6StrainRepository.h"
#include "DBManager/Repository/HDF5/Base/ResultRepositoryBase.h"

template <>
inline HighFive::DataType HighFive::create_datatype<SG::DataStructure::Post::TRIA6StrainData> ()
{
    HighFive::CompoundType ct = { { "EID", HighFive::create_datatype<SG::DataStructure::Common::Id> () },
                                  { "TERM", HighFive::create_datatype<char[4]> (), 1, true },
                                  { "GRID", HighFive::create_datatype<SG::DataStructure::Common::Id[4]> (), 8, true },
                                  { "FD1", HighFive::create_datatype<SG::DataStructure::Common::Real[4]> (), 8, true },
                                  { "X1", HighFive::create_datatype<SG::DataStructure::Common::Real[4]> (), 8, true },
                                  { "Y1", HighFive::create_datatype<SG::DataStructure::Common::Real[4]> (), 8, true },
                                  { "TXY1", HighFive::create_datatype<SG::DataStructure::Common::Real[4]> (), 8, true },
                                  { "FD2", HighFive::create_datatype<SG::DataStructure::Common::Real[4]> (), 8, true },
                                  { "X2", HighFive::create_datatype<SG::DataStructure::Common::Real[4]> (), 8, true },
                                  { "Y2", HighFive::create_datatype<SG::DataStructure::Common::Real[4]> (), 8, true },
                                  { "TXY2", HighFive::create_datatype<SG::DataStructure::Common::Real[4]> (), 8, true },
                                  { "DOMAIN_ID", HighFive::create_datatype<SG::DataStructure::Common::Id> () } };
    return ct;
}

SG_DBMANAGER_HDF5_NAMESPACE_OPEN
class TRIA6StrainRepository : public ITRIA6StrainRepository,
                              public SG::DBManager::HDF5::ResultRepositoryBase<SG::DataStructure::Post::TRIA6StrainData>
{
  public:
    TRIA6StrainRepository (SG::DBManager::HDF5Database& database);

    /**
     * @brief 初始化数据表的信息。
     */
    virtual void InitialDatasetInfo () override;
};
SG_DBMANAGER_HDF5_NAMESPACE_CLOSE
